import axios from "axios";
import curlirize from 'axios-curlirize';

// 定义一个变量用来存储 cURL 命令
let cURL = "";

// 初始化 axios-curlirize, 传入 axios 实例, 第二个参数为回调函数
curlirize(axios, (result, err) => {
    const { command } = result;
    cURL = command; // 拿到 cURL 命令
    if (err) {
        // use your logger here
    } else {
        // use your logger here
    }
});

axios.get("https://mock.presstime.cn/mock/682169d12f2a8bf3065bba3f/getTestData#!method=get")
    .then(res => {
        console.log("JSON", res.data)
        console.log("cURL", cURL)
    }).catch(error => {
        console.log(error)
    })